<?php
/**
 * oscshop2 B2C电子商务系统
 *
 * ==========================================================================
 * @link      http://www.oscshop.cn/
 * @copyright Copyright (c) 2015-2017 oscshop.cn. 
 * @license   http://www.oscshop.cn/license.html License
 * ==========================================================================
 *
 * @author    李梓钿
 *
 */ 
namespace osc\member\controller;
use osc\common\controller\MemberBase;
use think\Db;
class Wishlist extends MemberBase{
	
	protected function _initialize(){
		parent::_initialize();		
		$this->assign('breadcrumb','我的收藏');
	}
	
	function index(){
		
		$list=Db::view('Goods','goods_id,image,price,name,date_added')
		->view('MemberWishlist','uid','Goods.goods_id=MemberWishlist.goods_id')						
		->where(array('MemberWishlist.uid'=>UID))->paginate(config('page_num'));
		
		$this->assign('list',$list);
		$this->assign('empty','<tr><td colspan="20">没有数据~</td></tr>');
		$this->assign('SEO',array('title'=>'我的收藏-'.config('SITE_TITLE')));
		$this->assign('hashids',hashids());
		return $this->fetch();
	}
	function remove_wish(){		
		
		$id=hashids_decode(input('param.id'));
		
		if(!$id){
			$this->error('非法操作');
		}
		
		osc_service('common','member')->remove_wish($id,UID);
		
		storage_user_action(UID,member('username'),config('FRONTEND_USER'),'删除了收藏');
		
		$this->redirect('Wishlist/index');
	}
	
}
